package offer.algorithm;

/**
 * Description：
 * Author: zhangc
 * Date：2017/7/18 10:31
 */
public class ArraySearch3 {

    public static boolean searchNum(int[][] array,int dest){
        int length = array.length;
        int row = 0;
        int col = length-1;

        if(array[0][0] > dest || array[length-1][col] < dest)
            return false;

        while(row < length && col >= 0 && array[row][col] != dest ){
            if (array[row][col] == dest)
                break;
            if (array[row][col] < dest)
                ++ row;
            else
                -- col;
        }

        if(row < length && col >= 0)
            return true;
        return false;

    }

}
